package iBatis2;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;


/*
 *  Spring + ibatis Integration
 *  After inheriting SqlMapClientDaoSupport class, write DaoImp class.
 *  1. support class provides SqlMapClientTemplate object.
 *  	==> Thus, only pure CRUD code exits in dao implementation class. (No variable, no setter method)
 *  2. Preposition: Inheriting SqlMapClientDaoSupport, inject SqlMapClient object into Dao implementation class.
 */

public class DeptDaoImp extends SqlMapClientDaoSupport implements DeptDao {

	@Override
	public Object add(DeptVo vo) {
		// TODO Auto-generated method stub
		return getSqlMapClientTemplate().insert("add", vo);
	}
	


	@Override
	public Object replace(DeptVo vo) {
		// TODO Auto-generated method stub
		return getSqlMapClientTemplate().insert("replace", vo);

}



	@Override
	public int remove(int deptno) {
		// TODO Auto-generated method stub
		return getSqlMapClientTemplate().delete("remove", deptno);
	}

	@Override
	public int update(DeptVo vo) {
		// TODO Auto-generated method stub
		return getSqlMapClientTemplate().update("update", vo);
	}

	@Override
	public DeptVo info(int deptno) {
		// TODO Auto-generated method stub
		// The number of Select result is just 1.
		return (DeptVo)getSqlMapClientTemplate().queryForObject("info", deptno);
	}

	@Override
	public List<DeptVo> list() {
		// TODO Auto-generated method stub
		// Multiple results
		return getSqlMapClientTemplate().queryForList("list");
	}

}
